package com.rjyb.student_management_platform.dao;

import com.rjyb.student_management_platform.pojo.Student;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;


public interface UserDao {
    //1.
    @Select("select s.*,c.className from student s,class c,class_student cs where s.sid=cs.sid and cs.cid=c.cid and s.sid=#{q}")
    Map queryStudent(String q);
    //2.
    @Select("select * from student where name=#{name} and studentId=#{studentId}")
    Student ifStudent(@Param("studentId") String studentId, @Param("name") String name);
    //3.
    @Update("UPDATE  student SET name=#{name},password=#{password},studentId=#{studentId},sex=#{sex},age=#{age},birthday=#{birthday},phone=#{phone},idCard=#{idCard},address=#{address},nativePlace=#{nativePlace},nation=#{nation}\n" +
            "WHERE  name = #{name} and studentId=#{studentId}")
    boolean addStudent(Student student);
    //4.
    //学生修改密码
    @Update("update student set password=#{password} where sid=#{sid}")
    void upstudatapassword(@Param("password") String password, @Param("sid") long sid);



    //5.老师修改密码
    @Update("update teacher set password=#{password} where tid=#{tid}")
    void upteadatapassword(@Param("password") String password,@Param("tid") long tid);
}
